package com.main;

import com.actor.ClusterClientMasterActor;
import com.message.Message.UserInfo;
import com.message.TransformationMessages;
import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;
import com.util.BeanUtil;

import akka.actor.ActorSystem;
import akka.actor.Props;

public class ClientMain {

	public static void main(String[] args) {
		System.out.println("Start myAkkaClusterClient");
		BeanUtil.init();
		Config config = ConfigFactory.load("reference.conf");
		ActorSystem actorSystem = ActorSystem.create("akkaClusterTest", config);
		actorSystem.actorOf(Props.create(ClusterClientMasterActor.class),"myAkkaClusterClient");
		System.out.println("Started myAkkaClusterClient");

		UserInfo.Builder info = UserInfo.newBuilder();
		info.setId(2);
		info.setName("client1");
		for(;;){
			try {
				Thread.sleep(5000);
				TransformationMessages.WorldPacket sendToWorld = new TransformationMessages.WorldPacket((short)1, info.build().toByteArray());
				ClusterClientMasterActor.getInstance().sendToWrold(sendToWorld);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
}
